use validator_macro::Validator;

#[derive(Debug, Validator)]
struct MyStruct {
    #[validate(length(min = 2, max = 3), label = "姓名")]
    name: String,
    #[validate(length(min = 2, max = 10), label = "别名")]
    alias: Option<String>,
}

fn main() {
    let x = MyStruct {
        name: "zha".to_string(),
        alias: Some("afdsafdsafasddfsf".to_string()),
    };
    if let Err(e) = x.validae() {
        println!("{:?}", e);
    }
}
